package com.he.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.he.dto.CityRankingDTO;
import com.he.entity.ExpressDeliveryData;
import com.he.mapper.ExpressDeliveryDataMapper;
import com.he.service.ExpressDeliveryDataService;
import com.he.vo.CurrentVolumeVO;
import com.he.vo.DispatchDataVO;
import com.he.vo.EntryVolumeRatioVO;
import com.he.vo.GuangdongDataVO;
import com.he.vo.LogisticsFlowVO;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author a'abc
 * @description 针对表【express_delivery_data】的数据库操作Service实现
 * @createDate 2025-07-29 11:46:00
 */
@Service
public class ExpressDeliveryDataServiceImpl extends ServiceImpl<ExpressDeliveryDataMapper, ExpressDeliveryData>
        implements ExpressDeliveryDataService {
    @Resource
    ExpressDeliveryDataMapper eddm;

    @Override
    public Integer getCount() {
        return eddm.getCount();
    }

    @Override
    public CurrentVolumeVO currentVolume() {
        return eddm.currentVolume();
    }

    @Override
    public List<EntryVolumeRatioVO> entryVolumeRatio() {
        return eddm.entryVolumeRatioList();
    }


    //    - `type`（可选）：派件或寄件类型（1: 派件, 2: 寄件）
            //            - `company`（可选）：快递公司名称
    //- `packageType`（可选）：快件类型（1: 文件, 2: 物品）
    @Override
    public List<GuangdongDataVO> guangdongData(Integer type, String company, Integer packageType) {
        if (type == null || type == 2) {
            // 默认为寄件数据或明确指定为寄件
            return eddm.guangdongDataShipping(type, company, packageType);
        } else {
            // 派件数据
            return  eddm.guangdongDataDelivery(type, company, packageType);
        }
    }

    @Override
    public DispatchDataVO dispatchData(Integer type, String company, Integer packageType) {
        return eddm.dispatchData(type, company, packageType);
    }

    @Override
    public List<CityRankingDTO> provinceRankingShipping(String company, Integer packageType) {
        return eddm.provinceRankingShipping(company, packageType);
    }

    @Override
    public List<CityRankingDTO> provinceRankingDelivery(String company, Integer packageType) {
        return eddm.provinceRankingDelivery(company, packageType);
    }
    
    @Override
    public List<LogisticsFlowVO> getFlows(Integer cityId, Integer type, String startDate, String endDate, Integer companyId, Integer expressType) {
        if (type == 1) {
            // 派件数据
            return eddm.getFlows(cityId, startDate, endDate, companyId, expressType);
        } else {
            // 寄件数据，需要从ExpressShippingData中获取
            return eddm.getShippingFlows(cityId, startDate, endDate, companyId, expressType);
        }
    }
}